#ifndef __SOFT_TIMER_H
#define __SOFT_TIMER_H

#include "common.h"
#include "linklist.h"

typedef void (*TimerProc)(void *arg); /**<定时器回调函数*/

typedef enum {
    TIMER_MODE_PERIODIC,  // 产生周期性中断
    TIMER_MODE_ONE_SHOT   // 产生一次中断
} E_TimerMode;

typedef struct {
    uint32_t uMesc;
    uint32_t uCurTick;
    void (*fTimerProc)(void *arg);
    void *arg;
    bool bStop;
    E_TimerMode eMode;
    ListNode_t node;
} Timer_t;

void TimerInit(Timer_t *timer, uint32_t uMesc, E_TimerMode eMode, TimerProc timerProc, void *arg);
void TimerStart(Timer_t *timer);
void TimerStop(Timer_t *timer);
void TimerResume(Timer_t *timer);
void TimerReset(Timer_t *timer);
void TimerSetPeriod(Timer_t *timer, uint32_t uMesc);
void TimerSetProc(Timer_t *timer, TimerProc proc, void *arg);
void TimerMsHander(void);

#endif  //__TIMER_H
